package com.github.davidmoten.rx.jdbc;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

import java.sql.Connection;
import java.sql.SQLException;

import org.junit.Test;

public class ConnectionNonClosingTest {

    @Test
    public void testClose() throws SQLException {
        Connection con = mock(Connection.class);
        ConnectionNonClosing c = new ConnectionNonClosing(con);
        assertFalse(c.isClosed());
        c.close();
        verifyNoInteractions(con);
        c.clearWarnings();
        verify(con).clearWarnings();
        c.commit();
        verify(con).commit();
        c.createArrayOf(null, null);
        verify(con).createArrayOf(null, null);
        c.createBlob();
        verify(con).createBlob();
        c.createClob();
        verify(con).createClob();
        c.createNClob();
        verify(con).createNClob();
        c.createSQLXML();
        verify(con).createSQLXML();
        c.createStatement();
        verify(con).createStatement();
        c.createStatement(0, 0);
        verify(con).createStatement(0, 0);
        c.createStatement(0, 0, 0);
        verify(con).createStatement(0, 0, 0);
        c.createStruct(null, null);
        verify(con).createStruct(null, null);
        c.getAutoCommit();
        verify(con).getAutoCommit();
        c.getCatalog();
        verify(con).getCatalog();
        c.getClientInfo();
        verify(con).getClientInfo();
        c.getClientInfo(null);
        verify(con).getClientInfo(null);
        c.getHoldability();
        verify(con).getHoldability();
        c.getMetaData();
        verify(con).getMetaData();
        c.getNetworkTimeout();
        verify(con).getNetworkTimeout();
        c.getSchema();
        verify(con).getSchema();
        c.getTransactionIsolation();
        verify(con).getTransactionIsolation();
        c.getTypeMap();
        verify(con).getTypeMap();
        c.getWarnings();
        verify(con).getWarnings();
        assertTrue(c.isClosed());
        c.isReadOnly();
        verify(con).isReadOnly();
        c.isValid(0);
        verify(con).isValid(0);
        c.isWrapperFor(null);
        verify(con).isWrapperFor(null);
        c.nativeSQL(null);
        verify(con).nativeSQL(null);
        c.prepareCall(null);
        verify(con).prepareCall(null);
        c.prepareCall(null, 0, 0);
        verify(con).prepareCall(null, 0, 0);
        c.prepareCall(null, 0, 0, 0);
        verify(con).prepareCall(null, 0, 0, 0);
        c.prepareStatement(null);
        verify(con).prepareStatement(null);
        c.prepareStatement(null, 0);
        verify(con).prepareStatement(null, 0);
        c.prepareStatement(null, new int[] {});
        verify(con).prepareStatement(null, new int[] {});
        c.prepareStatement(null, new String[] {});
        verify(con).prepareStatement(null, new String[] {});
        c.prepareStatement(null, 0, 0);
        verify(con).prepareStatement(null, 0, 0);
        c.prepareStatement(null, 0, 0, 0);
        verify(con).prepareStatement(null, 0, 0, 0);
        c.releaseSavepoint(null);
        verify(con).releaseSavepoint(null);
        c.rollback();
        verify(con).rollback();
        c.rollback(null);
        verify(con).rollback(null);
        c.setAutoCommit(true);
        verify(con).setAutoCommit(true);
        c.setCatalog(null);
        verify(con).setCatalog(null);
        c.setClientInfo(null);
        verify(con).setClientInfo(null);
        c.setClientInfo(null, null);
        verify(con).setClientInfo(null, null);
        c.setHoldability(0);
        verify(con).setHoldability(0);
        c.setNetworkTimeout(null, 0);
        verify(con).setNetworkTimeout(null, 0);
        c.setReadOnly(true);
        verify(con).setReadOnly(true);
        c.setSavepoint();
        verify(con).setSavepoint();
        c.setSavepoint(null);
        verify(con).setSavepoint(null);
        c.setSchema(null);
        verify(con).setSchema(null);
        c.setTransactionIsolation(0);
        verify(con).setTransactionIsolation(0);
        c.setTypeMap(null);
        verify(con).setTypeMap(null);
        c.unwrap(null);
        verify(con).unwrap(null);
        c.abort(null);
        verify(con).abort(null);
    }

}
